extends CharacterBody2D

@export var cb:BaseContextBehavior
const SPEED = 300.0
const JUMP_VELOCITY = -400.0

func _ready() -> void:
	for child in get_tree().current_scene.get_parent().get_children():
		if child is BaseSystem:
			await child.init_system()
			print("{0} 初始化完毕!".format([child.name]))
	## 显示第一个场景
	var fade_in_first_scene_options = GameSceneSystem.create_options(1, "fade")
	var first_scene_general_options = GameSceneSystem.create_general_options(Color(0, 0, 0), 1, false)
	GameSceneSystem.show_first_scene(fade_in_first_scene_options, first_scene_general_options)
	#for i in range(1000):
		#var area = Area2D.new()
		#var shape = CollisionShape2D.new()
		#var s = CircleShape2D.new()
		#s.radius = 10
		#shape.shape = s
		#area.add_child(shape)
		#add_child(area)
	if not cb:
		return
	var arr:Array[BaseContextBehavior] = []
	arr.append(cb)
	%SBAgent.update_behaviors(self,arr)
func _physics_process(delta: float) -> void:
	# Add the gravity.
	#if not is_on_floor():
		#velocity += get_gravity() * delta

	# Handle jump.
	#if Input.is_action_just_pressed("ui_accept") and is_on_floor():
		#velocity.y = JUMP_VELOCITY

	# Get the input direction and handle the movement/deceleration.
	# As good practice, you should replace UI actions with custom gameplay actions.
	#var direction := Input.get_vector("ui_left", "ui_right","ui_up","ui_down")
	move_and_slide()
